package com.kbt.listener;

import android.app.Activity;
import android.view.Gravity;
import android.view.View;
import android.widget.PopupWindow;
import com.kbt.adapter.OrderBaseAdapter;
import com.kbt.model.data.OrderBean;
import com.kbt.model.data.OrderInfoModel;
import com.kbt.ui.CancelOrderPopWindow;
import com.kbt.ui.ConfirmOrderPopWindow;
import com.kbt.util.data.StaticData;

import java.util.List;

/**
 * @author zhgk
 * @package: com.kbt.listener
 * @TODO: 点击打开取消订单按钮
 * @data: 2015/8/20 13:46
 * @version: V1.0
 */
public class ClickConfirmOrderListener implements View.OnClickListener {

    private Activity context;
    private List<OrderBean> orderList;
    private OrderBaseAdapter orderAdapter;
    private int position;
    private int type;
    private View positionView;


    public ClickConfirmOrderListener(Activity context, View localView, OrderBaseAdapter orderWaitPayAdapter, List<OrderBean> orderList, int position, int type) {
        this.context = context;
        this.orderList = orderList;
        this.orderAdapter = orderWaitPayAdapter;
        this.position = position;
        this.positionView = localView;
        this.type = type;
    }

    @Override
    public void onClick(View v) {
        PopupWindow popupWindow;
        switch (type) {
            case StaticData.POPWINDOW_CANCEL_ORDER:
                popupWindow = new CancelOrderPopWindow(context, orderList, orderAdapter, position, positionView);
                break;
            case StaticData.POPWINDOW_CONFIRM_ORDER:
                popupWindow = new ConfirmOrderPopWindow(context, orderList, orderAdapter, position, positionView);
                break;
            default:
                popupWindow = new PopupWindow();
                break;
        }

        popupWindow.showAtLocation(positionView,
                Gravity.BOTTOM | Gravity.CENTER_HORIZONTAL, 0, 0);
    }

}
